#include "OpenglAppFramework/inc/TextureManager.h"
#include "OpenglAppFramework/inc/Shader.h"
#include <map>
#include "glad/inc/glad.h"

#include <iostream>

TextureManager::TextureManager() {}

void TextureManager::setTextureName(uint32_t texture_id, const std::string& sampler_name) {
    m_tex_id_name.push_back({texture_id, sampler_name});
}

void TextureManager::uploadShaderData(Shader* s) {
    uint32_t tex_unit_id = 1; // 0号采样器留给光照阴影
    for(const TextureIdNameItem& item : m_tex_id_name) {
        glActiveTexture(GL_TEXTURE0 + tex_unit_id);
        glBindTexture(GL_TEXTURE_2D, item.first);
        s->setInt(item.second, tex_unit_id);
//std::cout<<"tex_unit: " << item.second << " " << tex_unit_id<< std::endl;
        tex_unit_id += 1;
    }
}
